<?php
namespace Home\Controller;
use Think\Controller;
use Think\Verify;
class RegisterController extends Controller {
	
	public function __construct() {
		parent::__construct();
		if(empty($_SESSION['user']['id']))
		{
			$this->redirect('Home/Login/login');
		}
    }
	
    public function index(){
		if(IS_POST){
			$data['username'] = I('username');
			$aa	=	M('user_list') -> field('id') -> where($data) -> find();
			if(!empty($aa)){
				$res = 1;
			}else{
				$data['password'] = md5(I('password'));
				$data['type']     = I('type');
				$bb	=	M('user_list') -> add($data);
				if(!empty($bb)){ 
					$res = 2;
				}
			}
		}else{
			$res = 0;
		}
		$this -> assign('res',$res);
		$this->display();
    }

}